<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>学童管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="学童,管理">
	<meta http-equiv="description" content="This is my page">
	
  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="childrenManage.action" namespace="/inner/common">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'公共管理'},{'name':'学童管理'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
    		<s:hidden id="kindergartenId" name="kindergartenId"></s:hidden>
    		
    		<table cellspacing="1" width="100%" bgcolor="#CCCCCC">
				<tr bgcolor="#FFFFFF">
					<td align="right" width="10%" class="label">
						姓名：
					</td>
					<td align="left" width="23%">
						<s:textfield name="childvo.child.childName" id="childName" cssStyle="width:80%" cssClass="search"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						编号：
					</td>
					<td align="left" width="23%">
						<s:textfield name="childvo.child.childNum" id="childNum" cssStyle="width:80%" cssClass="search"></s:textfield>
					</td>
					<td align="right" width="10%" class="label">
						所属班级：
					</td>
					<td align="left" width="24%">
						<s:select name="childvo.classId" id="classId" value="%{childvo.classId}" list="classList" listKey="id" listValue="className" headerKey="" headerValue="--请选择--" cssStyle="width:120px" cssClass="search"></s:select>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td align="right" class="label">
						性别：
					</td>
					<td align="left">
						<s:select list='#{"男":"男", "女":"女"}' headerKey="" headerValue="--请选择--" name="childvo.child.sex" id="sex" cssStyle="width:120px" cssClass="search"></s:select>
					</td>
					<td align="right" class="label">
						入学时间：
					</td>
					<td align="left">
						<s:textfield name="childvo.entranceTimeStart" id="entranceTimeStart" cssStyle="width:100px" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" cssClass="WDate search"></s:textfield>
						-
						<s:textfield name="childvo.entranceTimeEnd" id="entranceTimeEnd" cssStyle="width:100px" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" cssClass="WDate search"></s:textfield>
					</td>
					<td align="right" class="label">
						是否在读：
					</td>
					<td align="left">
						<s:select list='#{1:"是",0:"否"}' headerKey="" headerValue="--请选择--" name="childvo.child.status" cssStyle="width:120px;" cssClass="search"></s:select>
					</td>
				</tr>
			</table>
    		
    		<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
						<input type="button" value="查询" class="btn" onclick="searchThis()"/>
						<my:hasPermission privilegeId="toAddChild">
						<input type="button" value="新增" class="btn" onclick="toAddChild()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="batchUpdateChild">
						<input type="button" value="批量" class="btn" onclick="toBatchUpdate()"/>
						</my:hasPermission>
						<input type="button" value="ToExcel" class="btn" onclick="exportChildren()"/>
						<input type="button" value="重置" class="btn" onclick="resetSearch()"/>
					</td>
				</tr>
			</table>
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr class="tableHead" align="center">
    				<td width="5%">
    					<input type="checkbox" onclick="cbCheck(this, 'childGroup')" />
    				</td>
    				<td width="10%">
    					序号
    				</td>
    				<td width="14%">
    					学童姓名
    				</td>
    				<td width="14%">
    					编号
    				</td>
    				<td width="8%">
    					性别
    				</td>
    				<td width="12%">
    					所属班级
    				</td>
    				<td width="12%">
    					入学日期
    				</td>
    				<td width="8%">
    					是否在读
    				</td>
    				<td width="20%">
    					操作
    				</td>
    			</tr>
    			<s:iterator value="lp.list" status="s">
    				<tr align="center"
    					<s:if test="#s.index%2==0">class="tableRow2" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow2'"</s:if>
						<s:else>class="tableRow1" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow1'"</s:else>
    				>
    					<td>
    						<input type="checkbox" name="childGroup" value="<s:property value='id' />" />
    					</td>
    					<td>
    						<s:property value="(pager.thisPage - 1) * pager.pageSize + #s.index + 1" />
    					</td>
    					<td>
    						<s:property value="childName"/>
    					</td>
    					<td>
    						<s:property value="childNum"/>
    					</td>
    					<td>
    						<s:property value="sex"/>
    					</td>
    					<td>
    						<s:property value="className"/>
    					</td>
    					<td>
    						<s:date name="entranceTime" format="yyyy-MM-dd"/>
    					</td>
    					<td>
    						<s:if test='1 == status'>
	    						是
    						</s:if>
    						<s:else>
    							<font color="red">否</font>
    						</s:else>
    					</td>
    					<td style="line-height:23px;">
    						<a href="javascript:toUpdateChild('<s:property value="id" />')"><s:property value="operateChn"/></a>
    						<my:hasPermission privilegeId="toAddTuition">
    						<a href="javascript:toSelectTemp('<s:property value="id" />')">交费</a>
    						</my:hasPermission>
    						<a href="javascript:childArrangeManage('<s:property value="id" />')">日程</a>
    						<br>
    						<my:hasPermission privilegeId="20">
    						<a href="javascript:paySituation('<s:property value="id" />', '<s:property value="childNum" />')">交费情况</a>
    						</my:hasPermission>
    						<my:hasPermission privilegeId="delChild">
    						<a href="javascript:delChild('<s:property value="id" />')">删除</a>
    						</my:hasPermission>
    					</td>
    				</tr>
    			</s:iterator>
    			<jsp:include page="/common/pager/pager.jsp">
					<jsp:param name="formName" value="frm" />
					<jsp:param name="id" value="1" />
				</jsp:include>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function toAddChild()
    {
    	var kgId = getTopKg();
    	var url = realPath + '/inner/common/toAddChild.action?kindergartenId=' + kgId +'&parentMethod=searchThis';
    	openWin(url, 700, 400, 'yes', 'yes');
    }
    
    function toUpdateChild(id)
    {
    	var kgId = getTopKg();
    	var url = realPath + '/inner/common/toUpdateChild.action?child.id=' + id + '&kindergartenId=' + kgId;
    	openWin(url, 700, 400, 'yes', 'yes');
    }

    function paySituation(childId, childNum)
    {
    	var kgId = getTopKg();
    	var url = realPath + '/inner/charge/tuitionManage.action?kindergartenId=' + kgId + '&tvo.childNum=' + childNum + '&child.id=' + childId;
    	window.location.href = url;
    }
    
    function delChild(id)
    {
    	showConfirm('确认删除？', function(v){
    		if(v == true)
    		{
    			var url = 'inner/common/delChild.action?child.id=' + id;
		    	ajaxAction(url, 'post', 'frm', true, function(result){
		    		if(result == true)
		    		{
	    				searchThis();
		    		}
		    		else
		    		{
		    			showMsg('该学童已付有学费，不能删除。');
		    		}
		    	});
    		}
    	});
    }
    
    function searchThis()
    {
    	$('#thisPage').val(1);
    	$('#frm').submit();
    }
    
    function toSelectTemp(childId)
    {
    	var kgId = getTopKg();
    	var obj = selectOneChargeTemp(kgId, childId);
   		if(obj != null)
   		{
   			if('temp' == obj.type)
   			{
	   			var url = realPath + '/inner/charge/toAddTuition.action?kindergartenId=' + kgId + '&tuition.child.id=' + childId + '&ct.id=' + obj.id;
	   			window.location.href = url;
	   		}
   			else if('manual' == obj.type)
   			{
   				var url = realPath + '/inner/charge/toAddTuitionManual.action?kindergartenId=' + kgId + '&tuition.child.id=' + childId;
   				window.location.href = url;
   			}
   		}
    }
    
    function childArrangeManage(id)
    {
    	var url = realPath + '/inner/common/childArrangeManage.action?cavo.childId=' + id;
    	window.location.href = url;
    }

    function toBatchUpdate()
    {
        var childIds = $('input:checkbox[name="childGroup"][checked]');
        if(childIds.length == 0)
        {
			showMsg('请选择学童。');
			return;
        }
        var ids = groupToString('childGroup', true);
    	var kgId = getTopKg();
		var url = realPath + '/inner/common/toBatchUpdate.action?kindergartenId=' + kgId + '&childIds=' + ids;
		showMd(url, 450, 200);
    }

    function exportChildren()
    {
    	var url = realPath + '/inner/common/exportChildren.action';
		document.forms['frm'].target = '_blank';
		document.forms['frm'].action = url;
		document.forms['frm'].submit();
		document.forms['frm'].action = realPath + '/inner/common/childrenManage.action';
		document.forms['frm'].target = '_self';
    }
    </script>
  </body>
</html>
